package com.oocl.ita.daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.oocl.ita.dao.ShopDao;
import com.oocl.ita.po.Shop;
import com.oocl.ita.util.DBUtil;

public class ShopDaoImpl implements ShopDao {

	public int addShop(Shop shop) {
		int m = 0;
		String sql = "insert into shop(shopId,merchantId,shopNumber,legalName,sPhone,"
				+ "address,shopName,signTime,available,sendTime,describe,"
				+ "startTime,endTime,icon,star,soldNum,status) "
				+ "values (shopId.nextval,merchantId.nextval,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		Connection connection = null;
		PreparedStatement pst = null;
		try {
			connection = DBUtil.connect();
				pst = connection.prepareStatement(sql);
				pst.setString(1, shop.getShopNumber());
				pst.setString(2, shop.getLegalName());
				pst.setString(3, shop.getsPhone());
				pst.setString(4, shop.getAddress());
				pst.setString(5, shop.getShopName());
				pst.setString(6, shop.getSignTime());
				pst.setInt(7, 0);
				pst.setString(8, shop.getSendTime());
				pst.setString(9, shop.getDescribe());
				pst.setString(10, shop.getStartTime());
				pst.setString(11, shop.getEndTime());
				pst.setString(12, shop.getIcon());
				pst.setInt(13, 0);
				pst.setInt(14, 0);
				pst.setInt(15, 0);
				m = pst.executeUpdate();

		} catch (SQLException e) {
			System.out.println("msg doen't insert in DB");
		} finally {
			DBUtil.free(connection, pst, null);
		}
		return m;
	}	
	
}
